
/**
 * 从头部获取token值
 * 判断AI回答是否结束
 */
import { PayloadAction, createSlice } from "@reduxjs/toolkit"; 
import {produce} from 'immer'
export type TokenType = {
    token:string,
    isend:boolean
}

const TokenSliceInitial:TokenType = {
    token:'',
    isend:true
}

const TokenSlice = createSlice({
    name:'TokenSlice',
    initialState:TokenSliceInitial,
    reducers:{
        setToken:produce((draft:TokenType,action:PayloadAction<string>)=>{
            draft.token = action.payload
        }),
        setIsEnd:produce((draft:TokenType,action:PayloadAction<boolean>)=>{
            draft.isend = action.payload
        })
    }
})

export const {setToken,setIsEnd} = TokenSlice.actions

export default TokenSlice.reducer